#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-(x)))
const int N=1e6+10;
int T,n,m,L,V,a[N],d[N],v[N],p[N],ct[N],mxp;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;++i){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;++i){
            cin>>p[i];
            mxp=max(p[i],mxp);
        }
        cout<<n<<0<<'\n';
    }
    return 0;
}
//Never Forget freopen("xx.in","r",stdin); !!!!!!
//Be attetion to the data range and Long Long !!!
//Force Solution must be started in 30 minutes!!!
